﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.OleDb;

namespace apparatus
{
    public partial class frmadmin : Form
    {
        public frmadmin()
        {
            InitializeComponent();
        }

        private void frmadmin_Load(object sender, EventArgs e)
        {
            this.userTableAdapter1.FillOperator(db1DataSet.user);
            for (int i = 0; i < this.db1DataSet.user.Count; i++)
            {
                listBox1.Items.Add(this.db1DataSet.user.Rows[i]["username"].ToString());
            }
        }

        private void listBox1_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                this.userTableAdapter1.FillByusername(db1DataSet.user, listBox1.SelectedItem.ToString());

                tbname.Text = db1DataSet.user.Rows[0]["username2"].ToString();
            }
            catch
            {
                tbname.Text = "";
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            if (tbpass1.Text == tbpass2.Text)
            {
                lblcheck.Text = "两次密码输入一致";
            }
            else
            {
                lblcheck.Text = "两次密码输入不一致";
            }
        }

        private void btnupdate_Click(object sender, EventArgs e)   //更新操作员信息
        {
            if (tbname.Text != "")
            { 
            
            
            
            }
        }

        private void btnuseradd_Click(object sender, EventArgs e)
        {
            this.userTableAdapter1.InsertUser(tbadduser.Text, tbaddusernames.Text, tbuserpass1.Text, "oper");
            listBox1.Items.Clear();
            this.userTableAdapter1.FillOperator(db1DataSet.user);
            for (int i = 0; i < this.db1DataSet.user.Count; i++)
            {
                listBox1.Items.Add(this.db1DataSet.user.Rows[i]["username"].ToString());
            }
            MessageBox.Show("用户添加成功！");
        }
    }
          
}
